package com.wy.panda.event;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * 事件发布器
 * 
 * @author wangyuan
 * @since 2020-11-12 23:17:14
 *
 */
@Component
public class PandaEventPublisher implements ApplicationContextAware, ApplicationEventPublisher {

    public static ApplicationContext applicationContext;
    
    @Override
    public void publishEvent(Object event) {
        applicationContext.publishEvent(event);
    }
    
    @Override
    public void publishEvent(ApplicationEvent event) {
        applicationContext.publishEvent(event);
    }
    
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        PandaEventPublisher.applicationContext = applicationContext;
    }

}
